package com.pengtu.entity.quality;

import java.util.Comparator;
import java.util.Date;
import java.util.Set;
import java.util.TreeSet;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Where;

import com.pengtu.entity.IdEntity;
import com.pengtu.entity.app.Attachment;

@Entity
@Table(name = "T_Q_FLOW_CHECK")
public class FlowCheck extends IdEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String projectId; // 工程
	private String flowCode; // 发文编号
	private Date checkDate; // 检查开始时间
	private Date checkEndDate;// 检查结束时间
	private String checkType; // 检查方式
	private String content; // 检查主要内容
	private String contentFile; // 检查发文附件
	private String remark; // 备注
	private String status; // 状态
	private String attendance;// 参与人员
	private int attendancecount;// 参与人员数量

	private String preparer; // 编制人
	private Date prepareDate; // 编制时间
	private String auditor; // 负责人
	private Date auditDate; // 校核时间
	private String auditIdea;// 审核意见
	private String verifier; // 审定人
	private Date verifyDate; // 审定时间
	private String verifyIdea;// 复核意见

	private Set<Attachment> attachmentSet = new TreeSet<Attachment>(
			new Comparator<Attachment>() {
				@Override
				public int compare(Attachment attFirst, Attachment attSecond) {
					// TODO Auto-generated method stub
					return attFirst.getCreateDate().compareTo(
							attSecond.getCreateDate());
				}
			});

	private String taskId; // 任务ID，非持久化属性

	/**
	 * projectId
	 * 
	 * @return the projectId
	 * @since 1.0.0
	 */
	@Column(name = "PID")
	public String getProjectId() {
		return projectId;
	}

	/**
	 * @param projectId
	 *            the projectId to set
	 */
	public void setProjectId(String projectId) {
		this.projectId = projectId;
	}

	@Column(name = "FLOWCODE")
	public String getFlowCode() {
		return flowCode;
	}

	public void setFlowCode(String flowCode) {
		this.flowCode = flowCode;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "CHECKDATE")
	public Date getCheckDate() {
		return checkDate;
	}

	public void setCheckDate(Date checkDate) {
		this.checkDate = checkDate;
	}

	/**
	 * checkEndDate
	 * 
	 * @return the checkEndDate
	 * @since 1.0.0
	 */
	@Temporal(TemporalType.DATE)
	@Column(name = "CHECKENDDATE")
	public Date getCheckEndDate() {
		return checkEndDate;
	}

	/**
	 * @param checkEndDate
	 *            the checkEndDate to set
	 */
	public void setCheckEndDate(Date checkEndDate) {
		this.checkEndDate = checkEndDate;
	}

	@Column(name = "CHECKTYPE")
	public String getCheckType() {
		return checkType;
	}

	public void setCheckType(String checkType) {
		this.checkType = checkType;
	}

	@Column(name = "CONTENT")
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Column(name = "CONTENTFILE")
	public String getContentFile() {
		return contentFile;
	}

	public void setContentFile(String contentFile) {
		this.contentFile = contentFile;
	}

	@Column(name = "STATUS")
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Column(name = "REMARK")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "PREPARER")
	public String getPreparer() {
		return preparer;
	}

	public void setPreparer(String preparer) {
		this.preparer = preparer;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "PREPAREDATE")
	public Date getPrepareDate() {
		return prepareDate;
	}

	public void setPrepareDate(Date prepareDate) {
		this.prepareDate = prepareDate;
	}

	@Column(name = "AUDITOR")
	public String getAuditor() {
		return auditor;
	}

	public void setAuditor(String auditor) {
		this.auditor = auditor;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "AUDITDATE")
	public Date getAuditDate() {
		return auditDate;
	}

	public void setAuditDate(Date auditDate) {
		this.auditDate = auditDate;
	}

	@Column(name = "VERIFIER")
	public String getVerifier() {
		return verifier;
	}

	public void setVerifier(String verifier) {
		this.verifier = verifier;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "VERIFYDATE")
	public Date getVerifyDate() {
		return verifyDate;
	}

	public void setVerifyDate(Date verifyDate) {
		this.verifyDate = verifyDate;
	}

	/**
	 * auditIdea
	 * 
	 * @return the auditIdea
	 * @since 1.0.0
	 */
	@Column(name = "AUDITIDEA")
	public String getAuditIdea() {
		return auditIdea;
	}

	/**
	 * @param auditIdea
	 *            the auditIdea to set
	 */
	public void setAuditIdea(String auditIdea) {
		this.auditIdea = auditIdea;
	}

	/**
	 * verifyIdea
	 * 
	 * @return the verifyIdea
	 * @since 1.0.0
	 */
	@Column(name = "VERIFYIDEA")
	public String getVerifyIdea() {
		return verifyIdea;
	}

	/**
	 * @param verifyIdea
	 *            the verifyIdea to set
	 */
	public void setVerifyIdea(String verifyIdea) {
		this.verifyIdea = verifyIdea;
	}

	@OneToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinColumn(name = "TABLEID")
	@Where(clause = " DELFLAG = 0")
	public Set<Attachment> getAttachmentSet() {
		return attachmentSet;
	}

	public void setAttachmentSet(Set<Attachment> attachmentSet) {
		this.attachmentSet = attachmentSet;
	}

	@Transient
	public String getTaskId() {
		return taskId;
	}

	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}

	/**
	 * attendance
	 * 
	 * @return the attendance
	 * @since 1.0.0
	 */
	@Column(name = "ATTENDANCE")
	public String getAttendance() {
		return attendance;
	}

	/**
	 * @param attendance
	 *            the attendance to set
	 */
	public void setAttendance(String attendance) {
		this.attendance = attendance;
	}

	/**
	 * attendanceCount
	 * 
	 * @return the attendanceCount
	 * @since 1.0.0
	 */
	@Column(name = "ATTENDANCECOUNT")
	public int getAttendancecount() {
		return attendancecount;
	}

	/**
	 * @param attendanceCount
	 *            the attendanceCount to set
	 */
	public void setAttendancecount(int attendancecount) {
		this.attendancecount = attendancecount;
	}

}
